<?php
/**
 * Created by PhpStorm.
 * User: Cloud
 * Date: 2018/4/18
 * Time: 9:37
 */
?>
<?php
/**
 * Created by PhpStorm.
 * User: Cloud
 * Date: 2018/4/17
 * Time: 10:41
 */
?>
<!DOCTYPE html>
<html>
<head>
    <!--[if lt IE 7]>
    <div class="ie6_error">还在用<strong>漏洞百出的IE6浏览器</strong>么？为了您的网络安全，请升级浏览器 <a target="_blank"
                                                                               href="http://browsehappy.com">立即升级</a>
    </div>
    <![endif]-->

    <meta charset="utf-8">
    <title>审批中心-账期提醒-文具1号</title>
    <meta name="description"
          content="文具1号作为上海办公用品供货商公司,专为世界500强企业及SOHO办公族提供网上商城一站式办公耗材批发及采购服务,一站式选购办公日用文具用品,厂家直销,好货又便宜【阳光采购就上文具1号 阳光价格 老板放心 品质保障 员工省力】"/>
    <meta name="keywords" content="办公用品,办公文具,办公文具网站,文具网站,办公用品网,文具采购网,金万年"/>
    <meta name="copyright" content="上海易推信息科技有限公司"/>
    <meta name="renderer" content="webkit">
    <base href="<?php echo base_url(); ?>"/>
    <link rel="shortcut icon" href="favicon.ico"/>
    <link rel="stylesheet" href="public/js/layui/css/layui.css">
    <link rel="stylesheet" type="text/css" href="public/css/base.css"/>
    <link rel="stylesheet" type="text/css" href="public/css/common.css"/>
    <link rel="stylesheet" type="text/css" href="public/css/cost-center.css"/>
    <link href="public/css/yuan.css" rel="stylesheet" type="text/css"/>
    <link rel="stylesheet" type="text/css" href="public/css/list_bought.css"/>
    <link rel="stylesheet" type="text/css" href="public/css/order-manage.css"/>
    <!--[if lte IE 9]>
    <script type="text/javascript" src="public/js/html5shiv-printshiv-3.js"></script>
    <![endif]-->
</head>
<body>
<div class="bg">
    <!--common - head -->
    <?php $this->load->view('common/header.php'); ?>
    <!--common - head end-->
    <?php if ($period==0):?>
        <div class="container mt30">
            <div class="my-center-container">
                <div class="my-center-sidebar">
                    <ul class="layui-nav layui-nav-tree layui-inline" lay-filter="demo">
                        <li class="layui-nav-item "><a href="">审批中心</a></li>
                        <li class="layui-nav-item layui-nav-itemed"><a  href="news/news_bill">账期提醒</a></li>
                        <li class="layui-nav-item"><a style="border-bottom:0;"  href="news/news_pull.php">消息通知</a></li>
                    </ul>
                </div>
                <div class="my-center-right" style="overflow:visible; border: none;background-color: #f9f9f9">


                    <div class="my-center-right-cont" style="padding: 0;">
                        <div class="order-manage-cont" style="margin-top:0; width:992px; padding: 0">
                            <div id="main-content">

                                <div class="bought-list">
                                    <p class="bought-list-tit">
                                        账期提醒
                                    </p>
                                    <span class="bought-list-none bg-img_nonedate"></span>
                                    <p class="bought-list-none-text ">
                                        您当前账户尚未开通账期
                                        <a href="<?php echo base_url(); ?>customer/admin_apply_for_period_user_index" class="color-blue">申请开通＞</a>
                                    </p>
                                </div>
                                <!--end bought-list-->
                            </div>

                        </div>
                    </div>
                </div>
            </div>
        </div>
    <?php else:?>

    <div class="container mt30">
        <div class="my-center-container">
            <div class="my-center-sidebar">
                <?php
                if (isset($this->session->customer_id)){
                    $sql = 'select identity,id from app_customer WHERE id = '.$this->session->customer_id;
                    $identitys = $this->db->query($sql)->row_array();
                    if ($identitys['identity'] == 1) {
                        $sql = "select is_account,account_period_type from app_admin WHERE customer_id = " . $this->session->customer_id;
                        $admin_info = $this->db->query($sql)->row_array();
                        if ($admin_info['is_account'] == 1) {
                            if ($admin_info['account_period_type'] == 2) {
                                $bills = $this->db->where('customer_id', $identitys['id'])->where('status', 0)->from('app_bill ')->get()->result_array();
                                $bills = count($bills);
                            } else {
                                $bills = $this->db->where('customer_id', $identitys['id'])->where(array('status' => 0, 'bill_date != ' => NULL))->from('app_bill ')->join('app_bill_month', 'app_bill_month.bill_id = app_bill.id')->get()->result_array();
                                $bills = count($bills);
                            }
                        }
                    }
                    $customer_id=$identitys['id'];
                    $news= $this->db->where('receiver_customer_id',$identitys['id'])->where('read_status',0)->from('message_history')->get()->result_array();
                    //获取admin下面的子辈和孙辈的(包含自己)
                    $member = $this->db->from('app_customer')->select("id")->where('parent_id',$customer_id)->get()->result_array();
                    $str[] = $customer_id;
                    foreach ($member as $k => $v) {
                        $str[] = $v['id'];
                    }
                    foreach ($member as $k => $v) {
                        $where = array('parent_id' => $v['id']);
                        $row = $this->db->from('app_customer')->select("id")->where($where)->get()->result_array();
                        foreach ($row as $key => $val) {
                            $str[] = $val['id'];
                        }
                    }
                    $count1 = $this->db->where_in('customer_id',$str)->where('status',2)->from('app_temp')->count_all_results();
                    $count2 = $this->db->where_in('customer_id',$str)->where('status',4)->from('app_temp')->count_all_results();
                    $count = $count1+$count2;
                    $newspull=count($news);

                }
                ?>
                <ul class="layui-nav layui-nav-tree layui-inline" lay-filter="demo">
                            <li class="layui-nav-item  "><a href="<?php echo base_url('approve/index?id=2'); ?>">审批中心（<?php echo $count; ?>）</a></li>
                    <?php if (isset($admin_info)): ?>
                        <?php if ($identitys['identity']==1 && $admin_info['is_account'] == 1 ): ?>
                            <li class="layui-nav-item layui-nav-itemed "><a href="<?php echo base_url('news/news_bill'); ?>">账期提醒（<?php echo $bills; ?>）</a></li>
                        <?php endif;?>
                    <?php endif;?>
                    <li class="layui-nav-item"><a style="border-bottom:0;" href="<?php echo base_url('news/news_pull'); ?>">消息通知<em>（<?php echo $newspull; ?>）</em></a></li>
                </ul>
            </div>
            <div class="my-center-right" style="overflow:visible; border: none;background-color: #f9f9f9">

                <div class="my-center-right-cont" style="padding: 0;">
                    <div class="order-manage-cont" style="margin-top:0; width:992px; padding: 0">
                        <div id="main-content">


                            <div class="bought-list">
                                <p class="bought-list-tit">
                                    账期提醒
                                </p>
                                <form class="skin-gray clearfix bought-search" action="" method="get" style="padding-bottom:0;">

                                    <div class="remide-box" gdata-spm="7" style="padding:5px 0">
                                        <ul>
                                            <li><a href="<?php echo base_url('news/news_bill'); ?>?statu=0" class="checkbox-icon<?php if ($status==0):?> select <?php endif;?>  ">待还款</a></li>
                                            <li><a href="<?php echo base_url('news/news_bill'); ?>?statu=1" class="checkbox-icon  <?php if ($status==1):?>select <?php endif;?> ">已还款</a></li>
                                            <li><a href="<?php echo base_url('news/news_bill'); ?>?statu=2" class="checkbox-icon <?php if ($status==2):?>select <?php endif;?> ">已延期</a></li>
                                        </ul>
<!--                                        <button class="J_MakePoint button search-btn" type="button" id="searchBtn">-->
<!--                                            <a href="--><?//= $nexturl ?><!--" >下一页</a>-->
<!--                                        </button>-->
                                    </div>
                                </form>
                                <div class="corporate-invoice-table-box w100 bg-fff">
                                    <table border="1" class="corporate-invoice-tab corporate-invoice-sp">
                                        <thead>
                                        <tr>
                                            <th>订单编号</th>
                                            <th>还款日期</th>
                                            <th>还款金额</th>
                                            <th>订单状态</th>
                                            <th width="220">操作</th>
                                        </tr>
                                        </thead>
                                        <tbody>
                                        <?php foreach ($bill as $bil): ?>
                                            <tr id="">
                                                <td><?php echo $bil['id']?></td>
                                                <td class="color-blue"><?php echo $bil['should_repayment_date'] ?></td>
                                                <td><?php echo $bil['money'] ?> </td>
                                                <?php if ($bil['status']==0):?>
                                                    <td> 待还款</td>
                                                    <td class="corporate-invoice-tab-time td02">
                                                        <p class="item-container-warn item-container-warn-list color-red pb0 mb0" style="border: 0">
                                                            <span class="icon bg-icon_warn_red" style="top:2px;">提示</span>
                                                            距离还款日仅剩<?php echo round((strtotime($bil['should_repayment_date'])-time())/3600/24); ?>天 <a href="<?php echo base_url('pay/index'); ?>?bn=<?php echo $bil['bill_bn'] ?>" class="corporate-invoice-tab-btn-submit">立即还款</a>
                                                        </p>
                                                    </td>
                                                <?php elseif ($bil['status']==1):?>
                                                    <td> 已还款</td>
                                                    <td class="corporate-invoice-tab-time td02">
                                                        已为您恢复额度<?php echo $bil['account_period_quota']-$bil['account_period_quota_used'] ?>元<br>
                                                        还款日：<?php echo $bil['actual_repayment_date'] ?>
                                                    </td>
                                                <?php elseif ($bil['status']==2):?>
                                                    <td> 已延期</td>
                                                    <td class="corporate-invoice-tab-time td02">
                                                        <p class="item-container-warn item-container-warn-list color-red pb0 mb0" style="border: 0">
                                                            <span class="icon bg-icon_warn_red" style="top:2px;">提示</span>
                                                            超出还款日<?php echo round((time()-strtotime($bil['should_repayment_date']))/3600/24)?>天 <a href="<?php echo base_url('pay/index'); ?>?bn=<?php echo $bil['bill_bn'] ?>" class="corporate-invoice-tab-btn-submit">立即还款</a>
                                                        </p>
                                                    </td>
                                                <?php endif;?>
                                            </tr>
                                        <?php endforeach;?>

                                        </tbody>
                                    </table>
                                    <!--<table class="layui-hide" id="test"></table>-->
                                    <div class="corporate-invoice-page-box">
                                        <?php if ($total_page > 1): ?>
                                            <?php if ($nowPage > 1): ?>
                                                <a href="<?= $preurl ?>" class="page-prev">上一页</a>
                                            <?php endif; ?>
                                            <?php if ($nowPage != $total_page): ?>
                                                <a href="<?= $nexturl ?>" class="page-next">下一页</a>
                                            <?php endif; ?>
                                        <?php endif; ?>
                                    </div>
                                </div>
                            </div>
                            <?php endif;?>

                            <!--end bought-list-->
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<?php $this->load->view('common/bottom.php'); ?>

<div class="mask none"></div>
<div class="pop corporate-invoice-img-pop none">
    <a href="javascript:;" class="close"></a>
    <img class="corporate-invoice-img" src="" alt="">
</div>


<script type="text/javascript" src="public/js/jquery.min.js"></script>
<script src="public/js/layui/layui.js"></script>
<script type="text/javascript" src="public/js/index.js"></script>
<script type="text/javascript" src="public/js/owl.carousel.min.js"></script>

<script>
    layui.use(['element', 'form', 'layedit', 'laydate', 'upload'], function () {
        var element = layui.element; //导航的hover效果、二级菜单等功能，需要依赖element模块
        var form = layui.form
            , layer = layui.layer
            , layedit = layui.layedit
            ,laydate = layui.laydate;
        var $ = layui.jquery
            , upload = layui.upload;

        //监听导航点击
        element.on('nav(demo)', function (elem) {
            //console.log(elem)
//      layer.msg(elem.text());
        });
        //日期
        laydate.render({
            elem: '#date-star'
        });
        laydate.render({
            elem: '#date-end'
        });
        laydate.render({
            elem: '#date'
        });
        //监听提交
        form.on('submit(demo1)', function (data) {
            layer.alert(JSON.stringify(data.field), {
                title: '最终的提交信息'
            });
            return false;
        });


    });
</script>
<script>
    $(function(){
        $(".checkbox-icon").click(function(){
            $(this).toggleClass('select');
            $(this).parent().siblings().find('.checkbox-icon').removeClass('select')
        });
    });
</script>
</body>
</html>

